<!DOCTYPE html>
<html ng-app="sales">
<head>
    <meta charset="UTF-8">
    <head>
        <base href="/">
    </head>
    <title>华成销售管理系统--销售--{{title}}</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="icon" type="image/x-icon" href="/favicon.ico">
    <link rel="stylesheet" type="text/css" href="/css/bootstrap.min.css">
    <link rel="stylesheet" type="text/css" href="/css/bootstrap-datetimepicker.min.css">
    <link rel="stylesheet" type="text/css" href="/css/font-awesome.min.css">
    <link rel="stylesheet" type="text/css" href="/css/new_ui.css">
    <link rel="stylesheet" type="text/css" href="/css/ag-grid.css">
    <link rel="stylesheet" type="text/css" href="/css/ag-material.css">
    <link rel="stylesheet" type="text/css" href="/css/status-color.css">
    <link rel="stylesheet" type="text/css" href="/css/sweetalert.css">

    <script src="/js/jquery-2.1.3.min.js"></script>
    <script src="/js/bootstrap.min.js"></script>
    <!-- <script src="/js/angular-1.5.8.min.js"></script> -->
    <script src="/js/angular.min.js"></script>
    <script src="/js/angular-animate.js"></script>
    <script src="/js/angular-route.min.js"></script>
    <script src="/js/jquery.shapeshift.min.js"></script>
    <script src="/js/bootstrap-datetimepicker.js"></script>
    <script type="text/javascript" src="/js/ag-grid.min.js"></script>
    <!-- <script src="/js/alert.js"></script> -->
    <script type="text/javascript" src="/js/sweetalert.min.js"></script>
</head>
<body>
    <div class="home-container">
        <div class="home-menu">
            <div class="home-menu-max">
                <div class="home-menu-max-img"><img src="/images/menu.png"></div>
                <div class="home-menu-max-logo"><img src="/images/logo.png"></div>
            </div>
            <div class="home-menu-list">
                <ul>
                    <!-- <div class="home-toggle-menu">
                        <img src="/images/menu.png">
                    </div> -->
                    <li ng-repeat='menu_item in menu'>
                        <a ng-click="open_module(menu_item,$index)" ng-class="{true:'bg-004881', false:''}[menu_item.icon == true]">{{menu_item.rolename}}</a>
                        <span class="home-arrow" ng-show="menu_item.icon"></span>
                    </li>
                </ul>
            </div>
            <div class="home-menu-set" ng-click="home_setting_bar = !home_setting_bar">
                <div class="home-menu-set-fa"><i class="fa fa-cog"></i></div>
            </div>
        </div>
        <div class="new-cover" ng-show="home_setting_bar" ng-click="home_setting_bar = !home_setting_bar" ng-init="open_me_data = false">
            <div class="me-data-container" ng-click="$event.stopPropagation()" ng-show="open_me_data">
                <ng-include src="'/modules/admin/me_data/me_data.inc.html'"></ng-include>
            </div>
            <div class="home-setting-bar " ng-click="$event.stopPropagation()">
                <ul>
                    <li ng-click="open_me_data = !open_me_data"><a>{{user.name}}<span>@{{user._shop.name}}</span></a> </li>
                    <li><a>
                        <i class="fa fa-book"></i>
                        <span style="cursor: pointer;" ng-click="toggle_help = !toggle_help">
                            帮助:{{toggle_help?"打开":"关闭"}}</span>
                    </a></li>
                    <li>
                        <a onclick="logout()" style="cursor: pointer;">
                            <i class="fa fa-sign-out"></i> <span>登出</span>
                        </a>
                    </li>
                </ul>
            </div>
        </div>
        <div class="home-view">
            <ng-view></ng-view>
        </div>
    </div>
    <div id="ycf-alert" class="modal">
      <div class="modal-dialog modal-sm">
        <div class="modal-content">
          <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button>
            <h5 class="modal-title"><i class="fa fa-exclamation-circle"></i> [Title]</h5>
          </div>
          <div class="modal-body small">
            <p>[Message]</p>
          </div>
          <div class="modal-footer" >
            <button type="button" class="btn btn-primary ok" data-dismiss="modal">[BtnOk]</button>
            <button type="button" class="btn btn-default cancel" data-dismiss="modal">[BtnCancel]</button>
          </div>
        </div>
      </div>
    </div>
<script src="/app.js"></script>
<script src="/main.js"></script>
<script src="/js/ui.js"></script>


<script>
    $(document).ready(function(){
        // $(window).resize(function(event) {
        //     var w = $(window).width();
        //     if (w <= '1024') {
        //         $(".home-menu-max-logo").hide();
        //     }
        // });
        $(".home-menu-max").click(function(event) {
            $(".home-menu-max-img").toggle();
            $(".home-menu-max-logo").toggle();
            $(".home-menu-list ul").toggle();
            $(".home-menu").toggleClass('menu-max');
            $(".home-view").toggleClass('view-max');
        });
        // $(".home-menu-list ul").click(function(event) {
        //     if ($(window).width() <= '1024') {
        //         $(".home-menu-max-img").toggle();
        //         $(".home-menu-max-logo").toggle();
        //         $(".home-menu-list ul").toggle();
        //         $(".home-menu").toggleClass('menu-max');
        //         $(".home-view").toggleClass('view-max');
        //     }
        // });


        /*sweet alert replacement*/
        // console.log(navigator.userAgent);
        if (navigator.userAgent.indexOf('Windows NT') > -1 || navigator.userAgent.indexOf('Linux') > -1){
            window.alert = function(txt){
                swal(txt);
            }
        }
        // window.confirm = function(txt,fn){
        //     var t = swal({
        //         title:txt,
        //         text:txt,
        //         type: "warning",
        //         showCancelButton: true,
        //         confirmButtonColor: "#DD6B55",
        //         confirmButtonText: "删除",
        //         closeOnConfirm: false
        //     });
        //      console.log(t);
        // }
    });
    //Submits an invalid authentication header, causing the user to be 'logged out'
    function logout() {
        $.post('/sys/logout',function(){
            $.ajax({
                type    : "GET",
                url     : "/api/sys/logout",
                dataType: 'json',
                async   : true,
                username: "!logout",
                password: "!logout",
                data    : 'i wanna logout'
            })
//In our case, we WANT to get access denied, so a success would be a failure.
                    .done(function () {
                        alert('Error!')
                    })
//Likewise, a failure *usually* means we succeeded.
//set window.location to redirect the user to wherever you want them to go
                    .fail(function () {
                        window.location = "/";
                    });
        });
    }
    $(".home-user").hover(function(){
        $(".home-user-logout").toggle();
    });


</script>
</body>
</html>
